home *** CD-ROM | disk | FTP | other *** search
- #include <dos.h>
- #include <conio.h>
-
- #define WORD unsigned int
-
- void DisplayPicture(WORD x,WORD y,char far * buffer,WORD xsize,WORD ysize);
-
- #include "PLACE YOUR IMAGE.TXT FILENAME HERE"
-
- void main(void)
- {
- WORD xsize = XSIZE FROM YOUR FILE;
- WORD ysize = YSIZE FROM YOUR FILE;
- char far *ImageBuffer = IMAGE;
-
- asm {
- mov ah, 0 // Set video mode 320x200, 256 colors
- mov al, 13h
- int 10h
- }
- getch();
- DisplayPicture(0, 0, ImageBuffer, xsize, ysize);
- getch();
- asm {
- mov ah, 0 // Set Text Mode 80x25 color
- mov al, 3h
- int 10h
- }
- }
-
- // VGA 320*200, flat mode, 256 color
- // image blitter. Could be sped up with REP MOVSD,
- // but images would have to be dividable by 4 with
- // no remainder. REP MOVSW would need images dividable
- // by 2 with no remainder. This one will accept any
- // size image.
-
- void DisplayPicture( unsigned int x,
- unsigned int y,
- char far * buffer,
- unsigned int xsize,
- unsigned int ysize )
- {
- asm {
- push ds
- mov ax, 0a000h // Load es with
- mov es, ax // Video Segment
- mov bx, y
- mov ax, 320 // Start = (y*320)+x
- imul bx
- add ax, x
- mov di, ax // into destination di
- mov bx, ysize // Read once so we keep memory
- // reads down.
- mov ax, xsize // Same here, read once
- mov dx, 320 // added after rep movsb to
- // place us one line down in
- sub dx, xsize // the next starting position
- lds si, buffer // Load si:di with buffer
- }
- drawloop:
- asm {
- mov cx, ax // Load xsize counter
- rep movsb // copy one line
- add di, dx // add offset for next line
- dec bx // Have we copied enough lines?
- jnz drawloop // Nope! Do some more then
- pop ds
- }
- }
-